package com.service.impl;


import com.dao.StudentDao;

import com.pojo.Student;

import com.service.StudentService;
import com.util.BaseDao;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentServiceImpl extends BaseDao implements StudentService {
    StudentDao dao;
    SqlSession session1;
    List<Student> list;
    Student student;

    @Override
    public List<Student> query() {
        session1=getSession();
        dao=getSession().getMapper(StudentDao.class);
        list= dao.query();
        closeSession(session1);
        return list;
    }

    @Override
    public void add(Student student) {
        session1=getSession();
        dao=getSession().getMapper(StudentDao.class);
        dao.add(student);
        closeSession(session1);
    }

    @Override
    public void del(Integer id) {
        session1=getSession();
        dao=getSession().getMapper(StudentDao.class);
        dao.del(id);
        closeSession(session1);
    }

    @Override
    public void update(Student student) {
        session1=getSession();
        dao=getSession().getMapper(StudentDao.class);
        dao.update(student);
        closeSession(session1);
    }

    @Override
    public Student queryById(Integer id) {
        session1=getSession();
        dao=getSession().getMapper(StudentDao.class);
        student= dao.queryById(id);
        closeSession(session1);
        return student;
    }
}
